import { decode,encode } from "js-base64";
// ws://127.0.0.1:5000/socket/battle
// wss://service-ee3bfr8j-1300311241.sh.apigw.tencentcs.com/release
let wssurl = `ws://${location.hostname}:5000/socket/battle`
if(import.meta.env.PROD){
    wssurl = `ws://${location.host}/socket/battle`
    // wssurl = 'ws://service-ee3bfr8j-1300311241.sh.apigw.tencentcs.com/release'
}
export const ws = new WebSocket(wssurl)

let count = 0
setInterval(()=>{
count ++
if(count > 10){
ws.send(JSON.stringify({type:'heart',data:'1'}))
count = 0
}
},1000)

ws.addEventListener('message',(ev)=>{
count = 0
})